import numpy as np
from ETO import ETO
from Get_Functions_details import get_functions_details

maxFunc = 23
SearchAgents_no = 30
Max_Iter = 500
runs = 30

for fn in range(1, maxFunc + 1):
    Function_name = f'F{fn}'
    LB, UB, Dim, Fobj = get_functions_details(Function_name)
    LB = np.ones(Dim)*LB
    UB = np.ones(Dim)*UB
    print("UB:", UB, "Shape:", np.shape(UB))
    Best_score_T = np.zeros(runs)
    AvgConvCurve = np.zeros(Max_Iter)
    Convergence_curve = np.zeros((runs, Max_Iter))

    for run in range(runs):
        Best_score, Best_pos, cg_curve = ETO(SearchAgents_no, Max_Iter, LB, UB, Dim, Fobj)
        Best_score_T[run] = Best_score
        Convergence_curve[run, :] = cg_curve

    Best_score_Best = np.min(Best_score_T)
    Best_Score_Mean = np.mean(Best_score_T)
    Best_Score_std = np.std(Best_score_T)

    print(
        f'{Function_name} Best: {Best_score_Best:.10f}     Mean: {Best_Score_Mean:.10f}     Std. Deviation: {Best_Score_std:.10f}')
